
package sr.codemg.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sr.codemg.entity.SysUsers;
import sr.codemg.service.SysUsersService;
import sr.codemg.vm.Base;
import sr.codemg.vm.Selects;
import sr.codemg.vm.Tables;

import java.util.Map;

/**
 * 用户信息
 **/
@Slf4j
@RestController
@RequestMapping("/sysusers")
public class SysUsersController {

    @Autowired
    SysUsersService sysUsersService;

    @GetMapping("/{account}")
    public SysUsers get(@PathVariable("account") String account) {
        return sysUsersService.get(account);
    }

    @PutMapping
    public Tables get(@RequestBody Map<String, Object> params) {
        return sysUsersService.findList(params);
    }

    @PostMapping
    public Base.Response post(@RequestBody SysUsers entity) {
        return sysUsersService.add(entity);
    }

    @PutMapping("/edit")
    public Base.Response put(@RequestBody SysUsers entity) {
        return sysUsersService.update(entity);
    }

    @DeleteMapping("/{account}")
    public Base.Response delete(@PathVariable("account") String account) {
        return sysUsersService.delete(account);
    }

    @PostMapping("/select")
    public Selects.Response select(@RequestBody Selects.Request req) {
        return sysUsersService.select(req);
    }

    @PutMapping("/reset/{account}")
    public Base.Response reset(@PathVariable("account") String account) {
        return sysUsersService.reset(account);
    }


}

